import sys
from django.conf import settings

class InvalidPaymentBackend(Exception):
	pass

class BasePaymentBackend(object):
	
	def create_payment(account, amount, recurring=False):
		raise NotImplementedError
		
	def delete_payment(payment_id):
		raise NotImplementedError
		

class DummyPaymentBackend(BasePaymentBackend):
	
	def __init__(self):
		self.stream = getattr(settings, 'DUMMY_PAYMENT_STREAM', None)
		if getattr(settings, 'DUMMY_PAYMENT_DEBUG', False):
			self.stream = sys.stdout
	
	def create_payment(self, account, amount, recurring=False):
		if self.stream:
			self.stream.write("create_payment(account=%s, amount=%s, recurring=%s)" % (account, amount, recurring))
		
	def delete_payment(self, payment_id):
		if self.stream:
			self.stream.write("delete_payment(payment_id=%s)" % payment_id)
